﻿@inherits EditOperationDialogBase<EmailServerConfigDto, Guid, EmailLocalResource>
@if (_editModel != null)
{

    <Form Loading="@_dialogLoading.Value"
            Model="@_editModel"
            LabelCol="new ColLayoutParam { Span = 6 }"
            WrapperCol="new ColLayoutParam { Span = 18 }"
            OnFinish="OnFormFinish"
            Context="model">
        <FormItem>
            <Input @bind-Value="@model.Name" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.Host" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.Port" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.FromEmail" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.AccountName" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.AccountPassword" Type="password" />
        </FormItem>
        <FormItem>
            <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Remark"></TextArea>
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.Tags" Type="hidden" />
            <SimpleSelect Mode="multiple" @bind-Values="@_tags">
                <SelectOptions>
                    @foreach (var gitem in EnumHelper.EnumToDictionary<EmailServerTag>())
                    {
                        <SimpleSelectOption Value="@(gitem.Key.ToString())" Label="@(Localizer[gitem.Value])"></SimpleSelectOption>
                    }
                </SelectOptions>
            </SimpleSelect>
        </FormItem>
        <FormItem>
            <Switch @bind-Value="@model.EnableSsl"></Switch>
        </FormItem>
        <FormItem>
            <Switch @bind-Value="@model.IsLocked"></Switch>
        </FormItem>
        @if (this.Options.Type.Equals(OperationDialogInputType.Edit) || this.Options.Type.Equals(OperationDialogInputType.Select))
        {
            <FormItem Label="@Localizer[nameof(SharedLocalResource.CreatedTime)]">
                <span>@model.CreatedTime.ToString(ClientConstant.DateTimeFormat)</span>
            </FormItem>
            <FormItem  Label="@Localizer[nameof(SharedLocalResource.UpdatedTime)]">
                <span>@model.UpdatedTime?.ToString(ClientConstant.DateTimeFormat)</span>
            </FormItem>
        }
        <FormItem WrapperColOffset="6" WrapperColSpan="18">
            <Space>
                @if (!OperationDialogInputType.Select.Equals(this.Options.Type))
                {
                    <SpaceItem>
                        <Button Type="@ButtonType.Primary" HtmlType="submit">
                            @Localizer[nameof(SharedLocalResource.Save)]
                        </Button>
                    </SpaceItem>
                }
                <SpaceItem>
                    <Button OnClick="_=>OnFormCancel()">
                        @Localizer[nameof(SharedLocalResource.Cancel)]
                    </Button>
                </SpaceItem>
            </Space>
        </FormItem>
    </Form>
}
